package KMW;

import java.util.Arrays;
import java.util.Scanner;

public class Manager {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int num = scanner.nextInt();
        Integer[] students = new Integer[num];
        for(int i = 0; i < num; i++){
            students[i] = scanner.nextInt();
        }
        //从大到小排序
        Arrays.sort(students,(a,b) -> -(a - b));
        Integer result = 0;
        int max = students[0];

        for (int i = 0; i < students.length; i++) {
            if(max > students[i]){
                max = students[i];
            }
            //不能再招生了
            if(max <= 0){
                break;
            }
            result += max;
            //如果有重复的
            while (i + 1 < students.length && students[i].equals(students[i + 1])){
                max = max - 1;
                if(max > 0){
                    result += max;
                }else {
                    break;
                }
                i++;
            }
            max = max - 1;
        }
        System.out.print(result);
    }
}
